<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="<s:url value="/css/style.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="<s:url value="/js/jquery-1.3.2.min.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.bgiframe.min.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.ajaxQueue.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/thickbox-compressed.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.autocomplete.js"/>"></script>
		<script type="text/javascript" src="<s:url value="/js/common.js"/>"></script>
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/jquery.autocomplete.css"/>" />
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/thickbox.css"/>" />
		<script type="text/javascript" src="<s:url value="/js/jquery-ui.js"/>"></script>
		<link href="<s:url value="/css/jquery.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="<s:url value="/js/jquery.blockUI.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/tableSel.js"/>"></script>
		<script type="text/javascript">
		function dosubmit(){
		    $('#listForm').submit();
		};
		function goEdit(){
			location.href='<s:url value="/customer/TM/edit"/>';
		};
		function doCall(id){
			var url = '<s:url value="/customer/TM/call?id="/>'+id;
            $('#'+id).find('td').attr('class','tablecolour1');
            window.open(url);
		}
        function doView(id){
			var url = '<s:url value="/customer/TM/view?id="/>'+id;
            $('#'+id).find('td').attr('class','tablecolour1');
            window.open(url);
		}
	   function changedisplay(el){
			el.toggle("fast",function() {
				 //$Container.getContainerProxy().resize();
			});
		}
		$(document).ready(function(){
		    $('#selCreateStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selCreateEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selLastTouchStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selLastTouchEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selSetApptStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selSetApptEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selShowStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selShowEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selPayStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selPayEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selAssignTmStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selAssignTmEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selInitVisitStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selInitVisitEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selTodoStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selTodoEndTime').datepicker( {dateFormat :'yy-mm-dd'});
            $("#selMarketingPlan").autocomplete("<s:url value="/marketing/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selMarketingPlan").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selMarketingPlanId").val(d.id);
            });
            $("#selAdChannel").autocomplete("<s:url value="/data/AdChannel/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selAdChannel").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selAdChannelId").val(d.id);
            });
            $("#selPTE").autocomplete("<s:url value="/data/PTE/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name+" "+d.wno;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name+" "+d.wno;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selPTE").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selPTEId").val(d.id);
            });
             $("#selCreateUser").autocomplete("<s:url value="/system/User/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selCreateUser").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selCreateUserId").val(d.id);
            });
            $("#selTM").autocomplete("<s:url value="/system/User/autoCompleteTMAjax.action"/>", {
               width: 300,
               minChars:1, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
             $("#selTM").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selTMId").val(d.id);
            });
             $("#selPTELead").autocomplete("<s:url value="/data/PTE/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name+" "+d.wno;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name+" "+d.wno;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selPTELead").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selPTELeadId").val(d.id);
            });
            $("#StatusTd :checkbox").each( function(i) {
                   if (i!=0){
		              $("<br/>").insertBefore($(this));
		           }
		    });
        });
		</script>
		<title><s:text name="system.title" />
		</title>
	</head>
	<body>
		<s:include value="/common/up.jsp"></s:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="box">
					<s:form action="TM/list" name="listForm" id="listForm"
						namespace="/customer">
						<input type="hidden" id="startIndex" name="startIndex" value="0" />
						<s:hidden name="ids" id="ids" />
						<table width="100%" border="0" cellpadding="0" cellspacing="0"
							class="searchbg">
							<tr>
								<td>
								    Name :
									<s:textfield  id="selName"  size="6" name="name" />
									Tel:
									<s:textfield  id="selTelephone" size="15" name="telephone" />
									TODO:
									<s:textfield  id="selTodoStartTime" name="selTodoStartTime" cssClass="input2" size="13" />-
									<s:textfield  id="selTodoEndTime" name="selTodoEndTime" cssClass="input2" size="13" /> 
									NoCC:<s:checkbox name="noCc"></s:checkbox>
									AllTm:<s:checkbox name="allUser"></s:checkbox>
								    <img src="<s:url value="/img/right/btns.gif"/>" border="0"  style="cursor:pointer"
										align="absmiddle" onclick="javascript:dosubmit();" />
									<img src="<s:url value="/img/right/btn-s2.gif"/>" border="0" style="cursor:pointer"
										align="absmiddle" onclick="javascript:changedisplay($('#div1'));"/> 
									<img src="<s:url value="/img/right/btn4.gif"/>" border="0"  style="cursor:pointer"
										align="absmiddle" onclick="javascript:reset2();" />
									&nbsp;
									<img onClick="javascript:goEdit();"   style="cursor:pointer"
										src="<s:url value="/img/right/btn1.gif"/>" border="0"
										align="absmiddle" />&nbsp;
                 				</td>
							</tr>
						</table>
						<div id='div1' style="display: none;">
							<table width="100%" border="0" cellpadding="0" cellspacing="0"
								bgcolor="#E0F5FF">
								<tr>
								  <td id="StatusTd" rowspan="8" >
								        &nbsp;Status:<br/>
										<s:checkboxlist id="selLeadsStatus" 
										    list="{'New','CallBack','NoAnswer','Notinterest','InvalidPhoneNumber','Dead','Duplicate','SetAppt','ShowUp'}"  
										    name="selLeadsStatus" ></s:checkboxlist  >
		        				    </td>
								</tr>
								<tr>
									<td height="40">
									    &nbsp;Type:
										<s:select  id="selLeadsType" name="leadsType" listKey="name()"
										    headerKey="" headerValue="--all--"
											list="@com.ef.constant.ELeadsType@values()"></s:select>
										&nbsp;Source:
										<s:select id="selLeadsSource"  name="leadsSource"  listKey="name()"
										    headerKey="" headerValue="--all--"
											list="@com.ef.constant.ELeadsSource@values()"></s:select>
										&nbsp;Ad Channel:
										<s:textfield id="selAdChannel"  name="adChannel.name" cssClass="input2" size="13" />
										<s:hidden id="selAdChannelId" name="adChannel.id"/>
										&nbsp;MarketingPolicy:
										<s:select  id="selMarketingPolicy"  name="marketingPolicy.id" 
										    headerKey=""  headerValue="--all--"
											list="marketingPolicyList"></s:select>
									</td>
								</tr>
								<tr>
									<td height="40">
										&nbsp;Init Visit Time:
										<s:textfield  id="selInitVisitStartTime" name="selInitVisitStartTime" cssClass="input2" size="13" />-
										<s:textfield  id="selInitVisitEndTime" name="selInitVisitEndTime" cssClass="input2" size="13" /> 
										&nbsp;CreateUser:
										<s:textfield  id="selCreateUser" name="createUser.name" cssClass="input2" size="10" /> 
										<s:hidden id="selCreateUserId" name="createUser.id"/>
										&nbsp;CreateTime:
										<s:textfield  id="selCreateStartTime" name="selCreateStartTime" cssClass="input2" size="10" />-
										<s:textfield  id="selCreateEndTime" name="selCreateEndTime" cssClass="input2" size="10" /> 
									</td>
								</tr>
								<tr>
									<td height="40">
									  	&nbsp;LastTouchTime:
										<s:textfield  id="selLastTouchStartTime" name="selLastTouchStartTime" cssClass="input2" size="10" />-
										<s:textfield  id="selLastTouchEndTime" name="selLastTouchEndTime" cssClass="input2" size="10" /> 
									     &nbsp;SetApptTime:
										<s:textfield  id="selSetApptStartTime" name="selSetApptStartTime" cssClass="input2" size="10"/>-
										<s:textfield  id="selSetApptEndTime" name="selSetApptEndTime" cssClass="input2" size="10"/>
										&nbsp;Assign Time:
										<s:textfield  id="selAssignTmStartTime" name="selAssignTmStartTime" cssClass="input2" size="10" />-
										<s:textfield  id="selAssignTmEndTime"name="selAssignTmEndTime" cssClass="input2" size="10" />    
									</td>
								</tr>
								<tr>
									<td height="40">
									  	&nbsp;Show Time:
										<s:textfield  id="selShowStartTime" name="selShowStartTime" cssClass="input2" size="10"/>-
										<s:textfield  id="selShowEndTime"name="selShowEndTime" cssClass="input2" size="10"/>
										&nbsp;Pay Time:
										<s:textfield  id="selPayStartTime" name="selPayStartTime" cssClass="input2" size="10" />-
										<s:textfield  id="selPayEndTime"name="selPayEndTime" cssClass="input2" size="10" />
									    &nbsp;Area:
										<s:textfield id="city"  name="city" cssClass="input2" size="10" />
										&nbsp;TmCall:
										<s:textfield id="selTmCall"  name="selTmCall" cssClass="input2" size="2" />
										&nbsp;Comments:
										<s:textfield id="selComments"  name="comments" cssClass="input2" size="8" />
									</td>
								</tr>
							</table>
						</div>
						<table width="100%" border="0" cellpadding="0" cellspacing="1"
							class="box2">
							<tr>
								<td class="tablecolour1">
									&nbsp;
								</td>
								<td class="tablecolour1">
									Leads Info
								</td>
								<td class="tablecolour1" nowrap="nowrap">
									Marketing Source/MK/PTE
								</td>
							 	<td class="tablecolour1" nowrap="nowrap">
									TouchTime/ToDo 
								</td>
								<td class="tablecolour1" nowrap="nowrap">
									Comments
								</td>
							 	<td class="tablecolour1" nowrap="nowrap">
									initVisit/Assigned/Show
								</td>
								<td class="tablecolour1" nowrap="nowrap">
									Status
								</td>
							 	<td class="tablecolour1" nowrap="nowrap">
									TM
								</td>
								<td class="tablecolour1" nowrap="nowrap">
									Function
								</td>
								<td class="tablecolour1" nowrap="nowrap">
									Area
								</td>
								<td class="tablecolour1" nowrap="nowrap">
									Call
								</td>
							</tr>
							<s:iterator value="listResult.items" status="status">
								<tr id='<s:property value="id" />'>
									<td class="tablecolour2">
										<s:property value="#status.index+1" />
									</td>
									<td class="tablecolour2" nowrap="nowrap">
									     <s:property value="name" /> 
									     <br/>
										 <s:property value="leadsType" />
									     <br/>
										 <s:property value="age" />
									</td>
									<td class="tablecolour2" nowrap="nowrap">
										<s:property value="leadsSource" />
										<br/>
									 	<s:property value="marketingPlan.name" />/
									 	<br/>
									 	<s:property value="pte.name" />
									</td>
									<td class="tablecolour2" nowrap="nowrap">
									    <s:date  name="lastEventTime" format='yyyy-MM-dd H:mm'/>
    									<br/>
										[ToDo]<s:date  name="nextEventTime" format='yyyy-MM-dd H:mm'/>
									</td>
									<td class="tablecolour2">
										<s:property value="comments" />
									</td>
									<td class="tablecolour2" nowrap="nowrap">
									    [I]<s:date  name="initVisitTime" format='yyyy-MM-dd H:mm'/> 
										<br/>
										[A]<s:date name="tmAssignTime" format="yyyy-MM-dd" /> 
										<br/>
										[S]<s:date name="showTime" format="yyyy-MM-dd" />
									</td>
									<td class="tablecolour2" nowrap="nowrap">
										<s:property value="leadsStatus" />
									</td>
							 		<td class="tablecolour2" nowrap="nowrap"> 
										<s:property value="tm.name" />
									</td>
									<td class="tablecolour2" nowrap="nowrap">
								    <s:set name ="tmid" value="tm.id" />
									<s:if test="isTMOwner(#tmid)">
									   <a href='<s:url value="/customer/TM/edit?id="/><s:property value="id"/>'>Edit</a>|
									   <a href='javascript:doCall(<s:property value="id" />)'>Call</a>
									</s:if> 
									<s:else>
									    <a href='javascript:doView(<s:property value="id" />)'>View</a>
									</s:else>
									</td>
									<td class="tablecolour2">
										<s:property value="city" />
									</td>
									<td class="tablecolour2">
										<s:property value="tmCall" />
									</td>
								</tr>
							</s:iterator>
						</table>
						<s:include value="/common/page.jsp"></s:include>
					</s:form>
				</td>
			</tr>
		</table>
		<s:include value="/common/down.jsp"></s:include>
	</body>
</html>